<script type="text/javascript">
	function insert(file)
	{
		$("#<?php echo $this->uri->segment(3)?>", top.document).val(file);
		parent.$.fn.colorbox.close();
	}
</script>
<?$seg2 = $this->uri->segment(2); ?>

<div class="media-upload-header">
    <ul id="menu">
        <li>
            <a href="<?php echo base_url()?>file_manager/img_lib/<?php echo $this->uri->segment(3)?>" <?if($seg2=='img_lib'){echo ' class="current"';}?>>
                <?php echo lang('file_mng_library');?>
            </a>
        </li>
        <li>
            <a href="<?php echo base_url()?>/file_manager/upload/<?php echo $this->uri->segment(3)?>" <?if($seg2=='upload'){echo ' class="current"';}?>>
                <?php echo lang('file_mng_upload_file');?>
            </a>
        </li>
    </ul>
</div>
<div class="form_upload">
    <div align="center" style="padding-top: 20px;">
        <?php echo form_open_multipart('file_manager/upload/'.$this->uri->segment(3)); ?>
        <table class="form">
            <tr>
                <td colspan="2"><?php if(!empty($message)) echo "<div style='border:1px solid #fdb735; background-color: #e9ffef; padding:10px;margin-bottom:10px'>".$message."</div>";?>
                    <?php if($this->session->flashdata('message')){
                        echo '<div class="message">'.$this->session->flashdata('message').'</div>';
                    }if($this->session->flashdata('error')){
                        echo '<div class="error">'.$this->session->flashdata('error').'</div>';
                    }if($this->session->flashdata('notes')){
                        echo '<div class="notes">'.$this->session->flashdata('notes').'</div>';
                    } ?>
                </td>
            </tr>
            
            <!--<tr>
                <td class="label"><?php echo lang('file_mng_category');?></td>
                <td>
                    <select id="file_image_cat_code" name="file_image_cat_code" class="w300">
                        <option value="">Chọn danh mục hình ảnh</option>
                        <?php foreach($opt_image_cat as $cat){
                            echo '<option value="'.$cat->code.'">'.$cat->name.'</option>'; 
                         }?>
                    </select>
                </td>
            </tr>
            <tr>
                <td class="label"><?php echo lang('file_mng_title');?></td>
                <td><input class="w300" type="text" name="title" value=""/></td>
            </tr>
            <tr>
                <td class="label"><?php echo lang('file_mng_title_en');?></td>
                <td><input class="w300" type="text" name="title_en" value=""/></td>
            </tr>
             <tr>
                <td class="label"><?php echo lang('file_mng_description');?></td>
                <td><textarea class="w300" name="description"></textarea></td>
            </tr>
             <tr>
                <td class="label"><?php echo lang('file_mng_description_en');?></td>
                <td><textarea class="w300" name="description_en"></textarea></td>
            </tr>
            <tr>
                <td class="label"><?php echo lang('file_mng_seo_keyword');?></td>
                <td><input class="w300" type="text" name="seo_keyword" value=""/></td>
            </tr>
            <tr>
                <td class="label"><?php echo lang('file_mng_seo_keyword_en');?></td>
                <td><input class="w300" type="text" name="seo_keyword_en" value=""/></td>
            </tr>-->
            <tr>
                <td class="label"><?php echo lang('file_mng_choose_file');?></td>
                <td>
                    <input type="file" name="filedata">
                    <input type="hidden" name="id" value="1">
                    <input class="button" type="submit" name="upload" value="Upload">
                </td>
            </tr>
        </table>
        <?php  echo form_close(); ?>
    </div>
    <?php if(isset($file_data)&&$file_data['err']=='')
	{
    ?>
    <table class="site">
        <tr>
            <td><a id="closelink" href="#" onclick="insert('<?php echo $file_data['name']?>');"><img src="<?php echo base_url_site().$dir_name.$file_data['name'];?>" height="50" alt=""></a></td>
            <td style="width: 150px"><a id="closelink" href="#" onclick="insert('<?php echo $file_data['name']?>');"><b><?php echo lang('file_mng_choose_file');?></b></a></td>
        </tr>
    </table>
    <?php }?>
</div>
